package online.indigo6a.eshop.service;

import online.indigo6a.eshop.model.CatalogBrand;
import online.indigo6a.eshop.model.CatalogItem;
import online.indigo6a.eshop.model.CatalogType;
import online.indigo6a.eshop.repository.CatalogBrandRepository;
import online.indigo6a.eshop.repository.CatalogItemRepository;
import online.indigo6a.eshop.repository.CatalogTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class CatalogService {
    @Autowired
    private CatalogItemRepository itemRepository;
    @Autowired
    private CatalogBrandRepository brandRepository;
    @Autowired
    private CatalogTypeRepository typeRepository;
    public Page<CatalogItem> getCatalogItemList(PageRequest page) {
        Page<CatalogItem> result = itemRepository.findAll(page);
        return result;
    }
    public Iterable<CatalogBrand> getCatalogBrandList() {
        return  brandRepository.findAll();
    }
    public Iterable<CatalogType> getCatalogTypeList() {
        return typeRepository.findAll();
    }
}
